<?php
/* @var $this ShopNavbarController */
/* @var $model ShopNavbar */
/* @var $form CActiveForm */
?>

<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'shop-navbar-_shopnavbar-form',
        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // See class documentation of CActiveForm for details on this,
        // you need to use the performAjaxValidation()-method described there.
        'enableAjaxValidation' => false,
        'htmlOptions' => array('enctype' => 'multipart/form-data'),
    ));
    ?>



    <?php echo $form->errorSummary($model); ?>


    <div class="form_left">
        <?php echo $form->labelEx($model, 'title'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'title',array('size' => 60, 'maxlength' => 100, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'title'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'url'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'url',array('size' => 60, 'maxlength' => 200, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'url'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'shopid'); ?>
    </div>
    <div class="form_right">
        <?php
        $session = new CHttpSession;
        $session->open();
        $userID = $session['user_salesmart'][3];

        $listshop = Shop::model()->findAll('flag in(1,4) and uid=' . $userID);

        $list = CHtml::listData($listshop, 'id', 'shopName');

        echo $form->dropDownList($model, 'shopid', $list, array('prompt' => '----- Chọn gian hang -----',
            'ajax' => array(
                'type' => 'POST', //request type
                'url' => CController::createUrl('manager/dynamiccategory'), //url to call.
                'update' => '#parentID', //selector to update
                'data' => array('id' => 'js:this.value'),
        )));?>
        <?php echo $form->error($model, 'shopid'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'parent'); ?>
    </div>
    <div class="form_right">
         <?php
        if (isset($model->shopid)) {
            $session = new CHttpSession;
            $session->open();
            //$session['user_salesmart'][3];

            $listsmenu = ShopNavbar::model()->findAll('parent=0 and flag=1 and shopid=' . $model->shopid);
            $listmenu = CHtml::listData($listsmenu, 'id', 'title');
            echo $form->dropDownList($model, 'parent', $listmenu, array('prompt' => '----- Chọn danh mục cha -----', 'id' => 'parentID'));
        } else {
            echo $form->dropDownList($model, 'parent', array(), array('prompt' => '----- Chọn danh mục cha -----', 'id' => 'parentID'));
        }
        ?>
        <?php echo $form->error($model, 'parent'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'flag'); ?>
    </div>
    <div class="form_right">
         <?php echo $form->dropDownList($model, 'flag', array('1' => 'Đang hiện','0' => 'Đang ẩn')); ?>
        <?php echo $form->error($model, 'flag'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'image'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->fileField($model, 'image', array('size' => 40, 'maxlength' => 50)); ?>
        <?php echo $form->error($model, 'image'); ?>
    </div>
    <div class="clear"></div>
        <div class="form_left">
        <?php echo $form->labelEx($model, 'position'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'position',array('class' => 'easyui-numberspinner', 'style' => 'width:80px;')); ?>
        <?php echo $form->error($model, 'position'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">.</div>
    <div class="row buttons">
        <?php echo CHtml::submitButton('Cập nhật'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->